home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / comm / appl1.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  8KB  |  231 lines

  1. /************************* APPL1 ****************************/
  2. #include "include.h"             /* @0224 */
  3. #include <malloc.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <state1.h>
  7. #define RESRU 19
  8. #define RESRH 16
  9. extern struct segprf *preqseg(int n);
  10. extern struct rqb *preqrq(int n);
  11. extern unsigned long findnau(void *np,void **naupp);
  12. extern void pattach(int n,char far *pdata,int len);
  13. extern void prelseg(struct segprf *wseg);
  14.  
  15. struct hscb *crhscb( char *mylu, char *partlu);
  16. struct hscb *findhscb( unsigned long ccor );
  17. struct rqb *memget( struct rqb *wrqb);
  18. struct rqb *rqopndst( struct rqb *wrqb);
  19. struct rqb *send( struct rqb *wrqb);
  20. struct rqb *rqclsdst( struct rqb *wrqb);
  21. struct rqb *exname( struct rqb *wrqb);
  22.  
  23.  
  24.      struct rqb *appl1(wrqbg)
  25.      struct rqb *wrqbg;
  26.      {
  27.         char parm;
  28.         struct rqb *memget();
  29.         parm=wrqbg->th.ra.rparm.parm.parm1;
  30.         switch (parm) {
  31.         case 0: return(rqopndst(wrqbg));
  32.         case 1: return(send(wrqbg));
  33.         case 3: return(rqclsdst (wrqbg));
  34.             case 5: return(memget(wrqbg)); /* only for DOS */
  35.             case 6: return(exname(wrqbg));
  36.             default:
  37.          return (NULL);
  38.                       }
  39.  
  40.  }/**************** end of appl1 *********************************/
  41. /********************** EXNAME ***********************************/
  42. struct rqb *exname(wrqb)
  43.       struct rqb *wrqb;
  44.        {
  45.         struct nau *wnau;
  46.         unsigned long rc;
  47.  
  48.               rc=findnau(&(wrqb->th.ra.wa.area[0]),&wnau);
  49.               if (rc == 0){
  50.                      pattach(0,NULL,0);
  51.                      return(wrqb);
  52.               }
  53.               return (NULL);
  54.        }
  55.  /****************************************************************/
  56.  /********************* MEMGET ***********************************/
  57.  struct rqb *memget(wrqb)
  58.       struct rqb *wrqb;
  59.        {
  60.          struct segprf *wseg;
  61.          struct rqb *wrqbn;
  62.              if (wrqb->th.ra.wa.rqba.rsrlen == 0)
  63.                      wrqb->th.ra.wa.rqba.area1=preqrq(1);
  64.               else
  65.                     {wseg=preqseg(wrqb->th.ra.wa.rqba.rsrlen);
  66.                      if (wseg==NULL) {
  67.                         wrqb->th.ra.wa.rqba.area1=NULL;
  68.              }
  69.                       else
  70.             { wrqbn=(char *)wseg+12;         /* 5001 */
  71.                           wrqb->th.ra.wa.rqba.area1=wrqbn;
  72.                         }
  73.                      }
  74.          wrqb->th.ra.code|=FROM;
  75.          return(wrqb);
  76.        }
  77.  /***************** end of memget ********************************/
  78.  /******************** OPNDST ************************************/
  79.  struct rqb *rqopndst (wrqbg)
  80.  struct rqb *wrqbg;
  81. {
  82.     struct nib *wnib;
  83.     unsigned long rc;
  84.     struct nau *wnau;
  85.     struct segprf *wseg, *wsegb;
  86.     struct rqb *wrqbb,*wrqbq;
  87.     struct bind *wbind;
  88.     struct rh *wrhb;
  89.     struct th *wthb;
  90.     struct hscb *whscb;
  91.     union ru *wru;
  92.     short i;
  93.     char *p, *t_wnib;
  94.      char bindhdr[3];
  95.  
  96.  
  97.      bindhdr[0]=0x6B;
  98.      bindhdr[1]=0x80;
  99.      bindhdr[2]=0x01;
  100.  
  101.     wru=(char*)wrqbg+RESRU;
  102.     if ((t_wnib=preqseg(sizeof(struct nib)-16)) == NULL) /* 5001 */
  103.  
  104.       {
  105.      return 0;
  106.       }
  107.     wnib=t_wnib+12;                        /* 5001 */
  108.     memcpy(wnib,wru,sizeof(struct nib));   /* 5001 */
  109.     rc=findnau(wnib->mode,&wnau);
  110.     if (rc!=NULL)
  111.                 return (NULL);
  112.      whscb=crhscb( wnib->mode,wnib->sym);
  113.      whscb->cor = whscb;
  114.      wsegb=preqseg(sizeof(struct bind)+3);     /*1350*/ /*5002*/
  115.      if (wsegb==NULL) {
  116.           return 0;}
  117.      wrqbb=(struct rqb *)((char*)wsegb+12);
  118.      wrhb=(char*)wrqbb+RESRH;
  119.      for (i=0;i<3;i++)
  120.        wrhb->rh[i]=bindhdr[i];
  121.      wbind=(char*)wrqbb+RESRU;
  122.      wbind->cmd=0x31;
  123.      wbind->bim.old.type=0x01;
  124.      wbind->crypt=0;
  125.      wbind->plulen=0x10;
  126.      wbind->slulen=0x10;
  127.        memcpy (wbind->plu,wnib->mode,8);       /* 1075 */
  128.        memcpy (wbind->slu,wnib->sym,8);       /* 1075 */
  129.        wbind->urclen=0x00;
  130.        wbind->usrlen=0x00;
  131.     memcpy (&(wrqbg->th.ra.wa.hh.rswa),&(wnib->user),4);
  132.     memcpy(&(wrqbg->th.ra.wa.area[0]),&(wnau->sid),2); /* @2005 */
  133.  
  134.     if(wnau->opnq==NULL)   /*place OPNDST RQB in queue*/
  135.            {wnau->opnq=wrqbg;
  136.             goto PATT;
  137.            }
  138.     wrqbq=wnau->opnq;
  139.     while(wrqbq->link!=NULL)
  140.             wrqbq=wrqbq->link;
  141.     wrqbq->link=wrqbg;
  142.     PATT:
  143.     p = wnib;
  144.     memset(p + 8, 0, 8);
  145.     prelseg(t_wnib);
  146.      wrqbb->th.ra.wa.hh.hscb=whscb;
  147.      wrqbb->th.ra.rparm.parm.parm1=0x08;
  148.      wthb=&(wrqbb->th.th);
  149.     memcpy(&(wthb->t912.old.snf),&(wnau->sid),2); /* @2005 */
  150.     wnau->sid++;
  151.      wthb->t912.old.dcf=(sizeof(struct bind)+3);     /*@2003 */
  152.      wthb->t13.lan.fid=FID8+EFI;         /* @0172 */
  153.      wthb->t13.lan.fid |= 0x0c;          /* 1068 */
  154.      wrhb=(char*)wrqbb+RESRH;
  155.      wrhb->rh[2]|=0x01;
  156.      wrqbb->th.ra.stcb=SESSA_CODE;
  157.      wrqbb->th.ra.code=0x02;
  158.      wrqbb->th.ra.code|=FROM;
  159.      wsegb->len = wthb -> t912.old.dcf;
  160.      pattach(1,wrqbb,wthb->t912.old.dcf);
  161.      return (wrqbg);
  162.     BADRSP:
  163.          /*building response RQB for LU62*/
  164.          wrqbg->th.ra.stcb=wrqbg->th.ra.wa.rqba.rsrlen+ST_N;
  165.      memcpy (&(wrqbg->th.ra.wa.hh.rswa),&(wnib->user),4);
  166.          wrqbg->th.ra.rparm.parm.parm1=5;
  167.          wrqbg->th.ra.rparm.parm.parm2=0xff;
  168.          wrqbg->th.ra.code=0xca;
  169.          return (NULL);
  170.   } /**********************end of opndst ****************************/
  171.   /*********************** SEND **************************************/
  172.   struct rqb *send (wrqbg)
  173.   struct rqb*wrqbg;
  174.  {
  175.     struct segprf *wseg;
  176.     struct rh *wrh;
  177.     struct th *wth;
  178.     wseg=(struct segprf *)((char*)wrqbg-12);
  179.     wrqbg->th.ra.rparm.parm.parm1=0;       /*@2001 */
  180.     wrh=(char*)wrqbg+RESRH;
  181.     wth=&(wrqbg->th.th);           /* @2005 */
  182.     wth->t912.old.dcf=wseg->len;          /* @2005 */
  183.  
  184.     wseg->un.th[0]=0x8c;
  185.     wrqbg->th.ra.stcb=DFC_CODE;
  186.     wrqbg->th.ra.code=0x02;
  187.     wrqbg->th.ra.code |= FROM;
  188.     pattach(1,wrqbg,wseg->len);
  189.        return (wrqbg);
  190.     } /************************** end of send ************************/
  191.     /******************** CLSDST *************************/
  192.     struct rqb *rqclsdst(wrqbg)
  193.     struct rqb *wrqbg;
  194.     {
  195.         struct segprf *wseg;
  196.         struct rqb *wrqb;
  197.         short i;
  198.     char unbndhdr[3];
  199.         struct rh *wrh;
  200.         struct th *wth;
  201.         struct hscb *whscb;
  202.         struct unbind *wun;
  203.  
  204.         unbndhdr[0]=0x6b;
  205.     unbndhdr[1]=0x80;
  206.     unbndhdr[2]=0x01;
  207.            whscb=findhscb(wrqbg->th.ra.wa.hh.hscb);
  208.            wseg=preqseg(25); /*segment request for unbind */
  209.            if (wseg==NULL)
  210.         {
  211.                   return (NULL);
  212.                 }
  213.            wrqb=(struct rqb *)((char*)wseg+12);
  214.            wrh=(char*)wrqb+RESRH;
  215.            for (i=0;i<3;i++)
  216.                 wrh->rh[i]=unbndhdr[i];
  217.            wun=(char*)wrqb+RESRU;
  218.            wun->cmd=0x32;
  219.            wun->type=0x01;
  220.            wrqb->th.ra.wa.hh.hscb=whscb->cor;
  221.            wth=&(wrqb->th.th);
  222.            wth->t13.lan.fid=0x8d;
  223.            wth->t912.old.dcf=(sizeof(struct unbind)+3);  /* @2005 */
  224.            wrqb->th.ra.stcb=SESSA_CODE;
  225.            wrqb->th.ra.code=0x02;
  226.            wrqb->th.ra.code |= FROM;
  227.            pattach(1,wrqb,wth->t912.old.dcf);
  228.               return ( wrqbg);
  229.    }/************************* end of clsdst ************************/
  230.   /******************* THE END ******************************************/
  231.